package com.mew.slots.core.game.mjk.service;

import com.alibaba.fastjson.JSON;
import com.mew.common.entity.game.WinFree;
import com.mew.slots.core.common.game.BaseGameService;
import com.mew.slots.core.common.game.vo.BasePlayMsgs;
import com.mew.slots.core.common.messge.response.SlotsPlayResponseMessage;
import com.mew.slots.core.common.vo.StrategyGameVO;
import com.mew.slots.core.game.klxg.bo.KlxgInRoom;
import com.mew.slots.core.game.klxg.bo.KlxgPlayMsgs;
import com.mew.slots.core.game.klxg.message.KlxgResponseMessage;
import com.mew.slots.core.game.klxg.roller.KlxgXml;
import com.mew.slots.core.game.klxg.room.KlxgRoom;
import com.mew.slots.core.game.mjk.bo.MjkInRoom;
import com.mew.slots.core.game.mjk.bo.MjkPlayMsgs;
import com.mew.slots.core.game.mjk.message.MjkResponseMessage;
import com.mew.slots.core.game.mjk.roller.MjkXml;
import com.mew.slots.core.game.mjk.room.MjkRoom;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

/**
 * @author Dylin
 */
@Service
@Slf4j
public class MjkService extends BaseGameService {
    @Override
    public BasePlayMsgs startGame(StrategyGameVO player) {
        MjkRoom room = new MjkRoom();
        room.init(player.getRollerId(), MjkXml.getInstance(),player.getWinFree().getFrees()>0,player.getInBetNumber(),player.getControlType());
        room.roundPlay();
        MjkPlayMsgs res =(MjkPlayMsgs)room.getRes();
        if(res.getBonusType()>0){
            player.getWinFree().setJson(JSON.toJSONString(new MjkInRoom()));
        }
        return res;
    }

    @Override
    public SlotsPlayResponseMessage myResp(WinFree winFree, BasePlayMsgs res) {
        MjkResponseMessage message = new MjkResponseMessage();
        MjkPlayMsgs pmres = (MjkPlayMsgs) res;
        message.setBonusType(pmres.getBonusType());
        message.setBonus(pmres.getBouns()>0?1:0);
        winFree.setBounsType(pmres.getBonusType());
        winFree.setBounsNumber(pmres.getBouns());
        return message;
    }
    @Override
    public void myAfterResp(SlotsPlayResponseMessage message,StrategyGameVO player, BasePlayMsgs res) { }
}
